/**
 * 
 */
package com.laozhao.EasySales.view;

import java.awt.FlowLayout;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JSeparator;

import com.laozhao.EasySales.model.AbstractModel;
import com.laozhao.EasySales.zgui.PopUpButton;
import com.laozhao.EasySales.zgui.ZPanel;

//import com.laozhao.model.entity.UserModel;


//import DBManager.bin.com.laozhao.DBManager.*;



/**
 * @author LaoZhao
 *
 */
public abstract class  AbstractPanel<E extends AbstractModel> extends ZPanel {

	protected E dataModel;
	protected String panelTitle;
	
	public JButton addButton = new JButton("Add"); 
	public JButton modifyButton = new JButton("Modify"); 
	public JButton deleteButton = new JButton("Delete"); 
	public PopUpButton dataFilterButton = new PopUpButton("Date Selector",PopUpButton.BOTTOM_LEFT); 
	/** dataFilterButton Group */
	private ButtonGroup dataFilterGroup = new ButtonGroup();

	/** Button to show all records. */
	private JRadioButtonMenuItem allMenuItem = new JRadioButtonMenuItem("All");

	/** Button to show today's records. */
	private JRadioButtonMenuItem todayMenuItem= new JRadioButtonMenuItem("Today");

	/** Button to show this month's records. */
	private JRadioButtonMenuItem monthMenuItem= new JRadioButtonMenuItem("Month");

	/** Button to show this year's records. */
	private JRadioButtonMenuItem yearMenuItem= new JRadioButtonMenuItem("Year");
	
	public AbstractPanel(){
		super();
	}

	public abstract E getDataModel();
	
	public abstract void init();
	
	public abstract String getTitle();
	
	protected ZPanel getControlPanel(){
		ZPanel searchPanel = new ZPanel(new FlowLayout());
		// searchButton.addActionListener(arg0);
		dataFilterGroup.add(allMenuItem);
		dataFilterGroup.add(todayMenuItem);
		dataFilterGroup.add(monthMenuItem);
		dataFilterGroup.add(yearMenuItem);
		
		dataFilterButton.add(allMenuItem);
		dataFilterButton.add(new JSeparator());
		dataFilterButton.add(todayMenuItem);
		dataFilterButton.add(monthMenuItem);
		dataFilterButton.add(yearMenuItem);
		dataFilterButton.add(new JSeparator());
		
		searchPanel.add(addButton);
		searchPanel.add(modifyButton);
		searchPanel.add(deleteButton);
		searchPanel.add(dataFilterButton);
		return searchPanel;
	}
	
}
